package cn.zpro.zookeeper.homework;

import cn.zpro.zookeeper.constant.Constants;
import cn.zpro.zookeeper.model.UserCenter;

import java.util.concurrent.TimeUnit;

/**
 * 测试Master选举的Demo
 * 模拟多进程
 */
public class MasterSelecterTest {

    public static void main(String[] args) {
        try {
            for (int i = 0; i < 10; i++) {
                UserCenter userCenter = new UserCenter();
                userCenter.setMc_id(i);
                userCenter.setMc_name("客户端" + i);
                MasterSelecter selecter = new MasterSelecter(Constants.getInstance(), userCenter);
                selecter.start();
                TimeUnit.SECONDS.sleep(1);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}
